<template>
  <div class="app-container">
    <div class="head-container">
      <div v-if="!crud.props.searchToggle">
        <el-form size="small" label-width="100px" v-formkey="{query:toQuery}">
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="业务日期">
                <div class="flex flex-row">
                  <el-date-picker
                    v-model="query.startTime"
                    align="right"
                    unlink-panels
                    class="fl1"
                    format="yyyy - MM - dd "
                    value-format="yyyy-MM-dd"
                    default-value
                    range-separator=""
                    placeholder="开始日期"
                  />
                  <el-date-picker
                    v-model="query.endTime"
                    align="right"
                    unlink-panels
                    class="fl1"
                    format="yyyy - MM - dd "
                    value-format="yyyy-MM-dd"
                    default-value
                    range-separator=""
                    placeholder="结束日期"
                  />
                </div>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="编码">
                <el-input    style="width: 100%" v-model="query.code"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="总店">
                <zSelect    style="width: 100%" :value.sync="query.pcustomerId" url="api/dropDown/basCustomerList" :params="{businessAttr:'3'}"
                         />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="销售区域">
                <JtgTree
                  style="width: 100%"
                  v-model="query.customerAreaId"
                  :initValue="query.customerAreaName"
                  :keyword="query.customerAreaId"
                  url="basCustomerAreaTree"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户">
                <zSelect :value.sync="query.customerId" url="api/dropDown/basCustomerList" :params="{businessAttr:'3'}"
                         style="width: 100%"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户分类">
                <JtgTree
                  style="width: 100%"
                  v-model="query.customerTypeId"
                  :initValue="query.customerTypeName"
                  :keyword="query.customerTypeName"
                  url="basCustomerTypeTree"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="业务员" prop="userId">
                <zSelect :value.sync="query.userId"    style="width: 100%" url="api/dropDown/sysUserList" :params="{businessAttr:'3'}"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="销售部门" prop="deptId">
                <zSelect :value.sync="query.deptId"    url="api/dropDown/childSysDeptList"
                         style="width:  100%"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="打印状态">
                <el-select
                  v-model="query.isPrint"
                  class="filter-item"
                  clearable
                  placeholder="打印状态"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.common_yes_or_no"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="状态">
                <el-select
                  v-model="query.orderStatus"
                  class="filter-item"
                  clearable
                  placeholder="状态"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.common_order_status"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="验收状态">
                <el-select
                  v-model="query.isAccept"
                  class="filter-item"
                  clearable
                  placeholder="验收状态"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.common_yes_or_no"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="核销状态">
                <el-select
                  v-model="query.cancelStatus"
                  class="filter-item"
                  clearable
                  placeholder="核销状态"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    label="全部"
                    value=""
                  />
                  <el-option
                    v-for="item in dict.common_cancel_status"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="入库仓库">
                <zSelect    style="width: 100%" :value.sync="query.warehouseId" url="api/dropDown/basWarehouseList" />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="是否往来">
                <el-select
                  v-model="query.isContact"
                  class="filter-item"
                  clearable
                  placeholder="请选择"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.common_yes_or_no"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="来源类型">
                <el-select
                  v-model="query.sourceType"
                  class="filter-item"
                  clearable
                  placeholder="请选择"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.t_ware_return_bottle_box_source_type"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="来源单据编号">
                <el-input    style="width: 100%"  v-model="query.sourceCode"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
            <el-row :gutter="10" >
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="备注">
                <el-input    style="width: 100%"  v-model="query.remark"></el-input>
              </el-form-item>
            </el-col>
              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="单据说明">
                <el-input     style="width: 100%" v-model="query.orderRemark"></el-input>
              </el-form-item>
            </el-col>
              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="二级代理">
                <zSelect :value.sync="query.sCustomerId" url="api/dropDown/basCustomerList" :params="{type:3}"
                         style="width:  100%;"/>
              </el-form-item>
            </el-col>
              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="驾驶员">
                <zSelect :value.sync="query.driverUserId"    style="width: 100%" url="api/dropDown/sysUserList" :params="{businessAttr:'5'}"
                />
              </el-form-item>
            </el-col>
            </el-row>
          <el-row :gutter="10" style="text-align: center">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="跟车员">
                <zSelect :value.sync="query.followUserId"    style="width: 100%" url="api/dropDown/sysUserList" :params="{businessAttr:'6'}"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <rrOperation :crud="crud"/>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!--工具栏-->
      <crudOperation :permission="permission">
        <el-button
          slot="left"
          class="filter-item"
          size="mini"
          type="primary"
          @click="crud.toDetail('wareReturnBottleBoxDetail')"
        >
          新增
        </el-button>
        <el-button
          slot="left"
          class="filter-item"
          size="mini"
          type="success"
          :disabled="crud.selections.length !== 1"
          @click="crud.toDetail('wareReturnBottleBoxDetail',crud.selections[0].id)"
        >修改
        </el-button>
<!--        <el-button-->
<!--          slot="right"-->
<!--          class="filter-item"-->
<!--          size="mini"-->
<!--          type="success"-->
<!--          :disabled="crud.selections.length !== 1"-->
<!--          :loading="crud.passLoading"-->
<!--          @click="crud.enableOrDisable('PASS')"-->

<!--        >-->
<!--          &lt;!&ndash;        v-permission="permission.pass"&ndash;&gt;-->
<!--          作废-->
<!--        </el-button>-->
<!--        <el-button-->
<!--          slot="right"-->
<!--          class="filter-item"-->
<!--          size="mini"-->
<!--          type="info"-->
<!--          :loading="crud.rejectLoading"-->
<!--          :disabled="crud.selections.length !== 1"-->
<!--          @click="crud.enableOrDisable('REJECT')"-->

<!--        >-->
<!--          &lt;!&ndash;        v-permission="permission.reject"&ndash;&gt;-->
<!--          取消作废-->
<!--        </el-button>-->
        <el-button
          slot="right"
          class="filter-item"
          size="mini"
          @click="crud.toAccept()"
          :disabled="crud.selections.length < 1"
          v-permission="permission.copy"
        >
          验收
        </el-button>
        <el-button
          slot="right"
          class="filter-item"
          size="mini"
          @click="crud.toUnAccept()"
          :disabled="crud.selections.length < 1"
          v-permission="permission.copy"
        >
          取消验收
        </el-button>
      </crudOperation>
      <el-dialog
        title="请选择打印模板"
        :visible.sync="crud.printConfig.pringDialog"
        width="30%"
      >
        <jPrintConfig groupId="wareReturnBottleBox"
                      v-if="crud.printConfig.pringDialog"
                      @getPrintId="crud.toPrint"
                      :isPreview="crud.printConfig.isPreview"
        ></jPrintConfig>
      </el-dialog>

      <vue-context-menu :contextMenuData="contextMenuData"
                        @tableConfig="tableConfig"
                        @deletedata="deletedata"></vue-context-menu>
      <!-- 表格配置 -->
      <el-dialog title="表格配置"
                 :visible.sync="tableConfigShow"
                 width="60%">
        <j-table-column-config :columns.sync="crud.header"  @tabSave="tabSave" @pit="pit" />
      </el-dialog>

      <!--表格渲染-->

      <el-table ref="table"  border
                height="700"
                show-summary
                @cell-dblclick="row=>crud.toEdit(row)"
                v-loading="crud.loading"
                :data="crud.data"
                size="small"
                style="width: 100%;"
                v-if="isShowTable"
                @header-dragend="changeColWidth"
                @contextmenu.native="showMenu"
                :summary-method="crud.sumRow"
                @row-click="crud.selectRow"
                :row-style="crud.rowClass"
                :row-class-name="crud.tableRowClassName"
                @selection-change="crud.selectionChangeHandler"
                @row-dblclick="crud.toDetailPlus('wareReturnBottleBoxDetail',$event.id)">
        <el-table-column :render-header="crud.renderHeader" type="selection" width="60" />
        <el-table-column :render-header="crud.renderHeader" type="index" width="60" label="序号"/>
        <el-table-column
          v-if="item.visible"
          v-for="(item, index) in crud.header"
          :key="`col_${index}`"
          :prop="item.prop"
          :label="columnLabel(item)"
          :width="item.width + 'px'"
          :data-porp='item.prop'
          @contextmenu.native="showMenu"
          @header-dragend="changeColWidth"
        >
          <!-- 自定义渲染模版 -->
          <template slot-scope="scope">
            <!-- 当列key为 sort 时，渲染一个手柄icon -->
            <template v-if="item.prop =='sort'">
              <div class="handle_move">
                <i :class="scope.row['sort']" />
              </div>
            </template>
            <template v-else>
              <span v-if="item.type == 1" style="margin-left: 0px">{{scope.row[`${item.prop}`]}}</span>
              <span v-if="item.type == 2" style="margin-left: 0px">{{ parseTime(scope.row[`${item.prop}`])}}</span>
              <span v-if="item.type == 3" style="margin-left: 0px">{{ getDict(`this.dict.label.${item.dictionary}["${scope.row[item.prop]}"]`) }}</span>
            </template>
          </template>
        </el-table-column>
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('code')" prop="code" label="编号" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('busDate')" prop="busDate" label="业务日期" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseDate(scope.row.busDate) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isContact')" prop="isContact" label="是否往来" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.common_yes_or_no,scope.row.isContact)  }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('loadCode')" prop="loadCode" label="配送单号" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerOrderCode')" prop="customerOrderCode" label="客户单号" width="100" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerCode')" prop="customerCode" label="客户编码" width="100" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerName')" prop="customerName" label="客户名称" width="100"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerName')" prop="customerName" label="二级代理" width="100"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerAreaName')" prop="customerAreaName" label="销售区域"  width="100"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerTypeName')" prop="customerTypeName" label="客户分类" width="100" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerTypeName')" prop="customerTypeName" label="所属总店" width="100" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerTypeName')" prop="customerTypeName" label="所属商场" width="100" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('userName')" prop="userName" label="业务员"  width="100"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('deptName')" prop="deptName" label="销售部门"  width="100"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('orderStatus')" align="center" label="状态" prop="orderStatus">-->
<!--          <template slot-scope="scope">-->
<!--            <el-tag>{{ dictName(dict.common_order_status,scope.row.orderStatus)  }}</el-tag>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('cancelStatus')" prop="cancelStatus" label="核销状态" >-->
<!--          <template slot-scope="scope">-->
<!--            <el-tag>{{ dictName(dict.common_cancel_status,scope.row.cancelStatus)  }}</el-tag>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceType')" align="center" label="来源类型" prop="sourceType">-->
<!--          <template slot-scope="scope">-->
<!--            <el-tag>{{ dictName(dict.t_ware_return_bottle_box_source_type,scope.row.sourceType)  }}</el-tag>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceCode')" prop="sourceCode" label="来源单据编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('boxCount')" prop="boxCount" label="箱数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('count')" prop="count" label="商品条数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('acceptTaxAmount')" prop="taxAmount" label="含税金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('acceptNoTaxAmount')" prop="noTaxAmount" label="未税金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('acceptTax')" prop="acceptTax" label="税额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('receiveTime')" prop="receiveTime" label="应收日期">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.receiveTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('cancelAmount')" prop="cancelAmount" label="已核销金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('unCancelAmount')" prop="unCancelAmount" label="未核销金额" />-->
<!--&lt;!&ndash;        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('discountAmount')" prop="discountAmount" label="折扣金额" />&ndash;&gt;-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('driverUserName')" prop="driverUserName" label="驾驶员" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('followUserName')" prop="followUserName" label="跟车员" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('warehouseName')" prop="warehouseName" label="入库仓库" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isPrint')" prop="isPrint" label="打印状态" >-->
<!--          <template slot-scope="scope">-->
<!--            <el-tag>{{ dictName(dict.t_print_config_type,scope.row.isPrint)  }}</el-tag>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('printCount')" prop="printCount" label="打印次数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('orderRemark')" prop="orderRemark" label="单据说明" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('remark')" prop="remark" label="备注" />-->

<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createUserName')" prop="createUserName" label="添加人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createTime')" prop="createTime" label="添加时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.createTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateUserName')" prop="updateUserName" label="修改人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateTime')" prop="updateTime" label="修改时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.updateTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditUserName')" prop="auditUserName" label="审核人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditTime')" prop="auditTime" label="审核时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.auditTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('cancelUserName')" prop="cancelUserName" label="核销人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('cancelDate')" prop="cancelDate" label="核销时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.cancelDate) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeUserName')" prop="closeUserName" label="关闭人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeTime')" prop="closeTime" label="关闭时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.closeTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-permission="['admin','buyOrderDetail:edit','buyOrderDetail:del']" label="操作" width="150px" fixed="right" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <udOperation-->
<!--              :data="scope.row"-->
<!--              :permission="permission"-->
<!--            />-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudWareReturnBottleBox from '@/api/erp/wareReturnBottleBox'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import { getAreaTree } from '@/api/erp/basCustomerArea'
import Treeselect from '@riophae/vue-treeselect'
import JtgTree from "@/components/Tree/JtgTreePlus";
import jPrintConfig from "../../../components/jPrintConfig/jPrintConfig";

import { publicListKey } from "@/utils/key";
import {getHeaderProperties} from "@/api/erp/headerProperties";
import {tablemixins} from "@/mixins/tablemixins";
import  jTableColumnConfig  from "@/components/jTableColumnConfig/jTableColumnConfig";

// crud交由presenter持有
const defaultCrud = CRUD({ title: '回瓶回箱明细',name:'wareReturnBottleBox', url: 'api/wareReturnBottleBox',
  optShow: {
    add: false,
    edit: false,
    del: true,
    download: true,
    leadingIn: true,
    enable: false,
    disable: false,
    pass: true,
    reject: true,
    printDetail:true,
    print: true,
    invalid: true,
    recover: true
  }, query:{
    startTime: null,endDate:null,dataExtent:null,
    cancelStatus: 0
  },  sort: 'id,desc', crudMethod: { ...crudWareReturnBottleBox }})
const defaultForm = {
    id: null,
    orderId: null,
    sourceDetailId: null,
    goodsId: null,
    goodsCode: null,
    goodsName: null,
    barcode: null,
    boxBarcode: null,
    helpSign: null,
    model: null,
    goodsBrandId: null, goodsBrandCode: null, goodsBrandName: null, goodsTypeId: null, goodsTypeCode: null, goodsTypeName: null, goodsTagId: null, goodsTagCode: null, goodsTagName: null, taxId: null, taxCode: null, taxName: null, taxRate: null, warehouseId: null, warehouseCode: null, warehouseName: null, locationId: null, locationCode: null, locationName: null, storehouseId: null, storehouseCode: null, storehouseName: null, batchNo: null, producedDate: null, deadlineDate: null, boxUnitId: null, boxUnitCode: null, boxUnitName: null, boxUnitCount: null, boxNum: null, mainUnitId: null, mainUnitCode: null, mainUnitName: null, mainUnitCount: null, mainNum: null, usableNum: null, usableBoxNum: null, goodsCount: null, boxCount: null, taxPrice: null, noTaxPrice: null, taxBoxPrice: null, noTaxBoxPrice: null, taxAmount: null, noTaxAmount: null, tax: null, discountRate: null, discountAmount: null, oldTaxPrice: null, oldNoTaxPrice: null, oldTaxBoxPrice: null, oldNoTaxBoxPrice: null, oldTaxAmount: null, oldNoTaxAmount: null, oldTax: null, acceptCount: null, acceptBoxCount: null, acceptTaxAmount: null, acceptNoTaxAmount: null, acceptTax: null, appendGoodsCount: null, appendBoxCount: null, unAppendGoodsCount: null, unAppendBoxCount: null, seq: null, remark: null, createUserId: null, createUserCode: null, createUserName: null, createTime: null, updateUserId: null, updateUserCode: null, updateUserName: null, updateTime: null }
export default {
  name: 'wareReturnBottleBox',
  components: { pagination, crudOperation, rrOperation, udOperation,Treeselect ,JtgTree, jPrintConfig,jTableColumnConfig },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud(),publicListKey,tablemixins],
  dicts: ['common_order_status','t_print_config_type','common_yes_or_no','common_cancel_status','t_ware_return_bottle_box_source_type'],
  data() {
    return {
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      permission: {
        add: ['admin', 'wareReturnBottleBox:add'],
        edit: ['admin', 'wareReturnBottleBox:edit'],
        del: ['admin', 'wareReturnBottleBox:del'],
        import: ['admin', 'wareReturnBottleBox:import'],
        export: ['admin', 'wareReturnBottleBox:export'],
        copy: ['admin', 'wareReturnBottleBox:copy'],
        upload: ['admin', 'wareReturnBottleBox:upload'],
        download: ['admin', 'wareReturnBottleBox:download'],
      },
      areaData: [],
      rules: {
        orderId: [
          { required: true, message: '单据id不能为空', trigger: 'blur' }
        ],
        goodsId: [
          { required: true, message: '商品id不能为空', trigger: 'blur' }
        ]
      }    }
  },
  watch: {
  },
  created() {
    getDepts
  },
  methods: {
    getDepts() {
      getAreaTree().then(res => {
        this.areaData = res
      })
    },
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
    getValue(e){
      this.query.startTime =this.query.dataExtent[0]
      this.query.endTime =this.query.dataExtent[1]
    },
    normalizer(node) {
      //去掉children=[]的children属性
      if (node.children == null || node.children.length == 0) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.name,
        children: node.children
      }
    }
  }
}
</script>

<style scoped>
  .table-img {
    display: inline-block;
    text-align: center;
    background: #ccc;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
</style>
